<?php

require_once __DIR__ . '/common.php';

/**
* @var PDO
*/
global $srcPDO;

/**
* @var PDO
*/
global $dstPDO;

$srcProjectIds = getSrcProjectIds();
$selectSrcProjectFormDataStmt = $srcPDO->prepare("select id, form_data from application_form_data where id = ?");
$insertDstProjectFormDataStmt = $dstPDO->prepare("insert into application_form_data (id, form_data) values (?, ?)");
foreach ($srcProjectIds as $srcProjectId) {
    echo "transfer project #$srcProjectId...\n";
    $selectSrcProjectFormDataStmt->execute([$srcProjectId]);
    $srcProject = $selectSrcProjectFormDataStmt->fetch(PDO::FETCH_NUM);
    $selectSrcProjectFormDataStmt->closeCursor();

    $insertDstProjectFormDataStmt->execute($srcProject);
}
